package cn.tedu.csmall.product.preload;

import cn.tedu.csmall.product.service.IBrandService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 缓存预热配置类
 *
 * @author java@tedu.cn
 * @version 0.0.1
 * @deprecated 0.0.1
 */
@Slf4j
// @Component
@Deprecated
public class CachePreload implements ApplicationRunner {

    @Autowired
    private IBrandService brandService;

    public CachePreload() {
        log.debug("创建开机自动启动对象：CachePreload");
    }

    // ApplicationRunner中的run()方法会在开机启动完成后的第一时间被自动调用
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.debug("开始执行CachePreload.run()，将进行缓存预热");
        brandService.rebuildCache();
    }

}
